package com.wanxi.controller;

import com.wanxi.VO.NavigationVO;
import com.wanxi.dto.ResultDTO;
import com.wanxi.service.NavigationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * 导航栏
 * @Author : 林子淳
 * @create 2023/3/10 16:58
 */
@RestController
public class NavigationController {
    @Autowired
    private NavigationService navigationService;
    @PostMapping("/back/navigation/add")
    @CrossOrigin
    protected ResultDTO add(NavigationVO navigationVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = navigationService.add(navigationVO);
        return resultDTO;
    }
    @PostMapping("/back/navigation/delete")
    @CrossOrigin
    protected ResultDTO delete(NavigationVO navigationVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = navigationService.delete(navigationVO);
        return resultDTO;
    }
    @GetMapping("/back/navigation/findAll")
    @CrossOrigin
    protected ResultDTO findAll(NavigationVO navigationVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = navigationService.findAll(navigationVO);
        return resultDTO;
    }
    @GetMapping("/back/navigation/findById")
    @CrossOrigin
    protected ResultDTO findById(NavigationVO navigationVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = navigationService.findById(navigationVO);
        return resultDTO;
    }
    @PostMapping("/back/navigation/update")
    @CrossOrigin
    protected ResultDTO update(NavigationVO navigationVO,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = navigationService.update(navigationVO);
        return resultDTO;
    }
}

